<template>
  <div class="add-card">

    <header class="add-header">
      <el-page-header content="告警详情" @back="$router.back()" />
    </header>

    <main class="add-main">
      <div class="form-container">
        <div class="title">告警详情</div>

        <!-- 
        el-form-item元素的prop属性绑定字段名name，表单验证时，
        就会验证el-input元素绑定的变量ruleForm.name的值是否符合验证规则 
        这里的prop没有用
        -->
        <!-- el-form-item 多行 -->
        <div class="form" >
          <div class="box1">
          <div class="form-item" >告警时间：{{ form.warningTime }}</div>
          <div class="form-item">告警区域：{{ form.areaName }}</div>
          <div class="form-item">故障类型：{{ form.errorType }}</div>
          <div class="form-item">一体杆名称：{{ form.poleName }}</div> 
          <div calss="form-item">一体杆编号：{{ form.poleNumber }}</div>
          <div class="form-item">处置状态：{{ formatStatus(form)  }} </div>
           </div>
        </div>
      </div>

      <div class="form-container">
        <div class="title">告警处理</div>
        <div class="form">
          <div class="box2">
          <div class="form-item">处理人：{{ form2.handleUser }}</div>
          <div class="form-item">处理结果：{{ form2.handleResult }}</div>
          <div class="form-item">联系方式：{{ form2.phonenumber }}</div>
          <div class="form-item">完成时间：{{ form2.handleTime }}</div>
          </div>
        </div>
      </div>

    </main>
  </div>
</template>

<script>
import { getDetailListAPI } from '@/api/pole';
export default {
data(){
  return{
    form:{
      warningTime:'',
      poleName:'',
      areaName:'',
      poleNumber:'',
      errorType:'',
      handleStatus:''
    },
    form2:{
      handleUser:'',
      phonenumber:'',
      handleResult:'',
      handleTime:''
    },
  }
},


mounted(){
 /*  const id = this.$route.query.id */
 /*   console.log('ID是',id) */ 
  //回显
  this.id = this.$route.query.id
  if(this.id){
    this.getDetail()
  }
},

methods:{

    async getDetail(){
    const res = await getDetailListAPI(this.id)
    const {  warningTime,poleName,areaName,poleNumber,errorType,handleStatus  } = res.data
    this.form = { warningTime,poleName,areaName,poleNumber,errorType,handleStatus }
    const {  handleUser,phonenumber,handleResult,handleTime  } = res.data
    this.form2 = { handleUser,phonenumber,handleResult,handleTime }
  },

  formatStatus(form){
    const status={
      0:'未派单',
      1:'已派单',
      2:'已接单',
      3:'已完成'
    }
    return status[form.handleStatus]
  }

}
}
</script>

<style scoped lang="scss">

.box1{
  //两列
  column-count: 2;
  font-size: 14px;
  line-height:2.5;
  
}

.box2{
  column-count: 2;
  font-size: 14px;
  line-height:2.5;

  /* text-align: right;
  text-align: left; 
  margin-right: 70px;
  margin-left: 30px; */
}

.add-card {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }
      .arrow{
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }

      .form {
        margin-bottom: 20px;
        padding: 20px 65px 24px;

        .el-form {
          display: flex;
          flex-wrap: wrap;

          .el-form-item {
            width: 50%;
          }
        }
      }
    }
    .preview{
      img{
        width: 100px;
      }
    }
  }

  .add-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 24px 50px;
    color: #000000d9;
    font-size: 14px;
    background: #fff;
    text-align: center;
  }
}
</style>